package com.longdaji.decoration.utils;

import java.text.DecimalFormat;

/**
 * Created by Kanade on 2018/3/29 0029.
 */

public class StringUtil {
    public static boolean isBlank(String str) {
        return str == null || str.length() == 0;
    }

    /**
     * 将数据保留两位小数
     */
    public static double getTwoDecimal(double num) {
        DecimalFormat dFormat = new DecimalFormat("#.00");
        String string = dFormat.format(num);
        Double temp = Double.valueOf(string);
        return temp;
    }

    public static String formatNumber(double value) {
        return String.format("%.2f", value);
    }

    public static String[] splitTime(String str) {
        return str.split(" ", 2);

    }

    public static boolean doubleIsZero(double num) {
        if (num >= (-1e-6) && num <= (1e-6)) {
            return true;
        }
        return false;
    }
}
